function 掉线重连()
x, y = ddzs(进入游戏[f],"进入游戏")
if x > -1 then
  if result["重连时"]== "立即重连" then
    mSleep(100)
  elseif result["重连时"]== "5分钟" then
    mSleep(300000)
  elseif result["重连时"]== "30分钟" then
    mSleep(1800000)
  elseif result["重连时"]== "一个小时" then
    mSleep(3600000)
  elseif result["重连时"]== "不连" then
    mSleep(360000000000)
  end
  tap (x,y)
  mSleep(500)
  for i=1,40 do
    x, y = ddzs(选择角色[f],"选择角色")
    if x > -1 then
      tap (x,y)
    end
    mSleep(500)
    x, y = ddzs(角色确定[f],"角色确定")
    if x > -1 then
      break
    end
    x,y=ddzs(道符[f],"在游戏页面")
    if x>-1 then
      return
    else
      mSleep(30)
    end
  end
  for i=1,35 do
    x, y = ddzs(角色确定[f],"角色确定")
    if x > -1 then
      tap (x,y)
      break
    else
      mSleep(500)
    end
    x,y=ddzs(道符[f],"在游戏页面")
    if x>-1 then
      return
    else
      mSleep(30)
    end		
  end
end


end

function 抢BOSS()
while true do
x,y=ddzs(点击对话[f],"NPC对话")
if x>-1 then
  tap(x,y)
  end
	mSleep(300)
end
end



function 剧情对话跳过()
x, y = ddzs(剧情跳过[f],"剧情跳过")
if x>-1 then
  tap(x, y)
  mSleep(1000)
end
end

function 关闭页面()
x,y=ddzs(关闭活动[f],"关闭窗口")
if x>-1 then
  tap(x,y)
else
  mSleep(300)
end
x,y=ddzs(关闭刷道[f],"关闭刷道")
if x>-1 then
  tap(x,y)
else
  mSleep(300)
end
x,y=ddzs(死了[f],"你死了")
if x>-1 then
  tap(x,y)
else
  mSleep(300)
end
x,y=ddzs(关闭队伍信息[f],"关闭队伍信息")
if x>-1 then
  tap(x,y)
else
  mSleep(300)
end


end



function 通用放在积分()
x5, y5 = ddzs(没在刷道[f],"回到刷道")
if x5 > -1 then
  tap(x5, y5)
end

end









function 通用退出队伍()
while true do
  关闭页面()
  x,y=ddzs(在任务[f],"在任务")
  if x>-1 then
    tap(x,y)
    mSleep(1000)
    关闭页面()
  end
  x2,y2=ddzs(道符[f],"在主页面")
  x,y=ddzs(没在组队[f],"没在组队")
  sysLog("x:"..x)
  if x>-1 and x2 > -1 then
    return
  elseif x2>-1 then
    if Proportion == 7 then
      tap(956,177)
    elseif 六九手机==1 then
      tap(1206,139)
    elseif 十六手机==1 then
      tap(1206,139)
    elseif 三五手机==1 then
      tap(1206,147)
    end
    mSleep(500)
    x,y=ddzs(已创建队伍[f],"已创建队伍")
    sysLog("已创建队伍:"..x)
    x3,y3=ddzs(队伍面板[f],"队伍面板")
    if x>-1 and x3>-1 then
      x,y=ddzs(创建队伍[f],"创建队伍")
      if x>-1 then
        tap(x,y)
			mSleep(1000)	
	      x,y=ddzs(同意队长[f],"退出队伍")
      if x>-1 then
        tap(x,y)			
      end
			end
    elseif x3>-1 and x==-1 then
      sysLog("队伍模板检测不在队伍")
      return
      
    end
    
    
  end
end
end





function 好爱答案获取器()
local http = require("G_libs.socket.http")
local ltn12 = require("G_libs.socket.ltn12")
local math_random = math.random
local function get_ran_key()
  math.randomseed(os.time())
  return math.random(0,9)..math.random(0,9)..math.random(0,9)..math.random(0,9)..math.random(0,9)..math.random(0,9)..math.random(0,9)..math.random(0,9)..math.random(0,9)..math.random(0,9)
end
local url = ""
function SendFile(MyUserStr, GameID, FilePath, TimeOut)
  local MyUserStr = MyUserStr or 0
  GameID = GameID or 5001
  TimeOut = TimeOut or 30
  http.TIMEOUT = timeout
  local files
  local file = io.open(FilePath,"rb")
  sysLog(FilePath)
  if file then
    files = file:read("*a")
    file:close()
  end
  local response_body = {}
  local get_ran_key2=get_ran_key()
  local boundary = "---------------------------7de3a916a0ab0"
  
  local datatable = {
    "--"..boundary.."\n",
    'Content-Disposition: form-data; name="userStr"\n\n',
    MyUserStr,
    "\n--"..boundary.."\n",
    'Content-Disposition: form-data; name="gameid"\n\n',
    GameID,
    "\n--"..boundary.."\n",
    'Content-Disposition: form-data; name="timeout"\n\n',
    TimeOut,
    "\n--"..boundary.."\n",
    'Content-Disposition: form-data; name="rebate"\n\n',
    "2529|2A8079AC9C86849E",
    "\n--"..boundary.."\n",
    'Content-Disposition: form-data; name="daili"\n\n',
    "Haoi",
    "\n--"..boundary.."\n",
    'Content-Disposition: form-data; name="kou"\n\n',
    "\n--"..boundary.."\n",
    'Content-Disposition: form-data; name="beizhu"\n\n',
    "\n--"..boundary.."\n",
    'Content-Disposition: form-data; name="ver"\n\n',
    "Web2",
    "\n--"..boundary.."\n",
    'Content-Disposition: form-data; name="key"\n\n',
    get_ran_key2,
    "\n--"..boundary.."\n",
    'Content-Disposition: form-data; name="img"; filename="post.png"\n',
    'Content-Type: image/png\n\n',
    files,
    "\n--"..boundary.."--"
  }
  local data = table.concat(datatable)
  url,post_ = getHaoiHost()
  local headers = {
    ["Accept"]= "*/*",
    ["Accept-Language"] = "zh-cn",
    ["Content-Type"] = "multipart/form-data; boundary=---------------------------7de3a916a0ab0",
    ["Host"] = post_ ,
    ["Content-Length"] = #data,
    ["Accept-Encoding"] = "gzip, deflate",
    ["User-Agent"] = "ben",
    ["Connection"] = "Keep-Alive",
    ["Expect"] = "100-continue"
  }
  
  local rep , code = http.request{
    url = "http://"..url.."/UploadAPI.aspx",
    method = "POST",
    headers = headers  ,
    source = ltn12.source.string(data),
    sink = ltn12.sink.table(response_body),
  }
  
  return response_body[1]
end

function GetAnswer ()--先把这里改改   host 是读取的url 里的 去掉冒号 后面的内容   你该我看着 
  local str = TID
  local str_ = "id="..str.."&r="..get_ran_key()
  local response_body = {}
  local headers = {
    ["Accept"]= "*/*",
    ["Accept-Language"] = "zh-cn",
    ["Content-Type"] = "application/x-www-form-urlencoded",
    ["Host"] = post_ ,
    ["Content-Length"] = #str_,
    ["Accept-Encoding"] = "gzip, deflate",
    ["User-Agent"] = "ben",
    ["Connection"] = "Keep-Alive",
  }
  
  local rep , code = http.request{
    url = "http://"..url.."/getanswer.aspx",
    method = "POST",
    headers = headers  ,
    source = ltn12.source.string(str_),
    
    sink = ltn12.sink.table(response_body),
  }
  return response_body[1]
end

function getHaoiHost()
  -- 获取好爱Host
  local useUrl
  fwqurl = {
    'http://1.haoi23.net/svlist.html',
    'http://2.haoi23.net/svlist.html',
    'http://3.haoi23.net/svlist.html',
    'http://4.haoi23.net/svlist.html',
    'http://0.haoi23.net/svlist.html'
  }
  local s=math.random(1,2)
  for i=1,5 do
    平板老君("获取服务器...")
    local res, code = http.request(fwqurl[s])
    sysLog(""..code)
    if code == 200 then
      s=s+1
      local b = string.find(res,":")
      url = string.sub(res,4,b+4)
      post_ =  string.sub(res,4,b-1)
      h="haoi23"
      j=url,post_;
      sysLog("服务器"..j)
      if string.find(j,h) ~= 0 then   --获取成功
        sysLog("获取到服务器地址")
        break
      else 
        url = 'sv13.haoi23.net:8009'
        post_ = 'sv13.haoi23.net'
      end
    end
  end
  if code ~= 200 then   --获取失败
    url = 'sv13.haoi23.net:8009'
    post_ = 'sv13.haoi23.net'
  end
  return url,post_;
end
end





function 避过老君高峰期()
while true do 
  当前时=tonumber( os.date("%H", os.time()))
  if 当前时 >= cong and 当前时 <= dao then
    mSleep(5000)
  else
    break
  end
end

end



